#ifndef __UI_API_H__
#define __UI_API_H__

typedef struct
{
	void			(*Print)( const char *string );
	void			(*Error)( const char *string );
	int				(*Milliseconds)( void );
	void			(*Cvar_Register)( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
	void			(*Cvar_Update)( vmCvar_t *vmCvar );
	void			(*Cvar_Set)( const char *var_name, const char *value );
	float			(*Cvar_VariableValue)( const char *var_name );
	void			(*Cvar_VariableStringBuffer)( const char *var_name, char *buffer, int bufsize );
	void			(*Cvar_SetValue)( const char *var_name, float value );
	void			(*Cvar_Reset)( const char *name );
	void			(*Cvar_Create)( const char *var_name, const char *var_value, int flags );
	void			(*Cvar_InfoStringBuffer)( int bit, char *buffer, int bufsize );
	int				(*Argc)( void );
	void			(*Argv)( int n, char *buffer, int bufferLength );
	void			(*Cmd_ExecuteText)( int exec_when, const char *text );	// don't use EXEC_NOW!
	int				(*FS_FOpenFile)( const char *qpath, fileHandle_t *f, fsMode_t mode );
	void			(*FS_Read)( void *buffer, int len, fileHandle_t f );
	void			(*FS_Write)( const void *buffer, int len, fileHandle_t f );
	void			(*FS_FCloseFile)( fileHandle_t f );
	int				(*FS_GetFileList)(  const char *path, const char *extension, char *listbuf, int bufsize );
	int				(*FS_Seek)( fileHandle_t f, long offset, int origin ); // fsOrigin_t
	qhandle_t		(*R_RegisterModel)( const char *meshName, const char *skelName );
	qhandle_t		(*R_RegisterSkin)( const char *name );
	qhandle_t		(*R_RegisterShaderNoMip)( const char *name );
	void			(*R_ClearScene)( void );
	void			(*R_AddRefEntityToScene)( const refEntity_t *re );
	void			(*R_AddPolysToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
	void			(*R_AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
	void			(*R_RenderScene)( const refdef_t *fd );
	void			(*R_SetColor)( const float *rgba );
	void			(*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
	void			(*R_ModelBounds)( clipHandle_t model, vec3_t mins, vec3_t maxs );
	void			(*UpdateScreen)( void );
	int				(*CM_LerpTag)( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );
	void			(*S_StartLocalSound)( sfxHandle_t sfx, int channelNum );
	sfxHandle_t		(*S_RegisterSound)( const char *sample, qboolean compressed );
	void			(*Key_KeynumToStringBuf)( int keynum, char *buf, int buflen );
	void			(*Key_GetBindingBuf)( int keynum, char *buf, int buflen );
	void			(*Key_SetBinding)( int keynum, const char *binding );
	qboolean		(*Key_IsDown)( int keynum );
	qboolean		(*Key_GetOverstrikeMode)( void );
	void			(*Key_SetOverstrikeMode)( qboolean state );
	void			(*Key_ClearStates)( void );
	int				(*Key_GetCatcher)( void );
	void			(*Key_SetCatcher)( int catcher );
	void			(*GetClipboardData)( char *buf, int bufsize );
	void			(*GetClientState)( uiClientState_t *state );
	void			(*GetGlconfig)( glconfig_t *glconfig );
	int				(*GetConfigString)( int index, char* buff, int buffsize );

	int				(*LAN_GetServerCount)( int source );
	void			(*LAN_GetServerAddressString)( int source, int n, char *buf, int buflen );
	void			(*LAN_GetServerInfo)( int source, int n, char *buf, int buflen );
	int				(*LAN_GetServerPing)( int source, int n );
	int				(*LAN_GetPingQueueCount)( void );
	void			(*LAN_ClearPing)( int n );
	void			(*LAN_GetPing)( int n, char *buf, int buflen, int *pingtime );
	void			(*LAN_GetPingInfo)( int n, char *buf, int buflen );
	void			(*LAN_LoadCachedServers)();
	void			(*LAN_SaveCachedServers)();
	void			(*LAN_MarkServerVisible)(int source, int n, qboolean visible);
	int				(*LAN_ServerIsVisible)( int source, int n);
	qboolean		(*LAN_UpdateVisiblePings)( int source );
	int				(*LAN_AddServer)(int source, const char *name, const char *addr);
	void			(*LAN_RemoveServer)(int source, const char *addr);
	void			(*LAN_ResetPings)(int n);
	int				(*LAN_ServerStatus)( char *serverAddress, char *serverStatus, int maxLen );
	int				(*LAN_CompareServers)( int source, int sortKey, int sortDir, int s1, int s2 );
	int				(*MemoryRemaining)( void );
	void			(*GetCDKey)( char *buf, int buflen );
	void			(*SetCDKey)( char *buf );
	void			(*R_RegisterFont)(const char *pFontname, int pointSize, fontInfo_t *font);
	void			(*S_StopBackgroundTrack)( void );
	void			(*S_StartBackgroundTrack)( const char *intro, const char *loop);
	int				(*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits);
	e_status		(*CIN_StopCinematic)(int handle);
	e_status		(*CIN_RunCinematic )(int handle);
	void			(*CIN_DrawCinematic )(int handle);
	void			(*CIN_SetExtents )(int handle, int x, int y, int w, int h);
	int				(*RealTime)(qtime_t *qtime);
	void			(*R_RemapShader)( const char *oldShader, const char *newShader, const char *timeOffset );
	qboolean		(*VerifyCDKey)( const char *key, const char *chksum);

	void			(*SetPbClStatus)( int status );
} uiImports_t;

typedef struct
{
	int (*GetAPIVersion)();

	void (*Init)();
	void (*Shutdown)();
	void (*KeyEvent)(int key, int down);
	void (*MouseEvent)(int dx, int dy);
	void (*Refresh)(int realtime);
	qboolean (*IsFullscreen)();
	void (*SetActiveMenu)(uiMenuCommand_t menu);
	qboolean (*ConsoleCommand)( int realTime );
	void (*DrawConnectScreen)( qboolean overlay );
	qboolean (*HasUniqueCDKey) ();
} uiExports_t;

#endif
